package com.NewsServlet;

import com.NewsService.NewsService;
import com.NewsServiceImpl.NewsServiceImpl;
import com.entity.News;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class NewsUpdataServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        String name =  req.getParameter("name");
        String newsid=  req.getParameter("newsid");
        if(newsid !=null || newsid !=""){
            int num =Integer.parseInt(newsid);
            NewsService service = new NewsServiceImpl();
            News news = service.ServiceSselectById(num);
            HttpSession session=req.getSession();
            session.setAttribute("news",news);
            req.getRequestDispatcher("ModifyNews.jsp").forward(req
                    ,resp);
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
